{{define "title"}}
后台登录
{{end}}

{{define "header_css"}}
<link rel="stylesheet" href="/static/pearadmin/component/pear/css/pear.css" />
<link rel="stylesheet" href="/static/pearadmin/admin/css/other/login.css" />
{{end}}

{{define "body_class"}} background="/static/pearadmin/admin/images/background.svg" style="background-size: cover;" {{end}}
{{define "main"}}

<form class="layui-form" action="javascript:void(0);">
    <div class="layui-form-item">
        <img class="logo" src="/static/pearadmin/admin/images/logo.png" />
        <div class="title">后台登录</div>
        <div class="desc">
            gin + pear-admin 通用后台管理系统
        </div>
    </div>
    <div class="layui-form-item">
        <input placeholder="账号" name="username" lay-verify="required" hover class="layui-input"  />
    </div>
    <div class="layui-form-item">
        <input type="password" placeholder="密码" name="password" lay-verify="required" hover class="layui-input"  />
    </div>
    
    <div class="layui-form-item">
        <button type="button" class="pear-btn pear-btn-success login" lay-submit lay-filter="login">
            登 入
        </button>
    </div>
</form>

{{end}}

{{define "footer_script"}}

<script>
    layui.use(['form', 'button', 'popup','jquery','layer'], function() {
        var form = layui.form;
        var button = layui.button;
        var popup = layui.popup;

        var $ = layui.jquery;
		var layer = layui.layer;
        
        // 登 录 提 交
        form.on('submit(login)', function(data) {
            
            layer.load();
            $.ajax({
                type: "POST",
                data: data.field,
                success: function (res) {
                    console.log(res);
                    if (res.code == 1) {
                        layer.msg(res.msg, { icon: 1, time: 500 }, function () {
                            location.href = '/admin/index';
                        })
                    } else {
                        layer.msg(res.msg, { icon: 2, time: 2000 }, function () {
                            //initCode();
                        })
                    }

                    layer.closeAll('loading');
                }
            });

			return false;
        });
    })
</script>

{{end}}